<template>
  <MainLayout
    :role-name="'工艺工程师'"
    :system-title="'质量管理系统'"
    :base-route-path= loginInfo.redirectUrl
    :user-name=userInfo.name
  >
    <template #menu-items>
      <el-menu-item index="/process-engineer/home">
        <el-icon style="color: #fff;"><HomeFilled /></el-icon>
        <span style="color: #fff;">首页</span>
      </el-menu-item>
      <el-sub-menu index="1">
        <template #title>
          <el-icon style="color: #fff;"><Setting /></el-icon>
          <span style="color: #fff;">质检标准管理</span>
        </template>
        <el-menu-item index="/process-engineer/raw-material-standard">
          <el-icon style="color: #fff;"><Box /></el-icon>
          <span style="color: #fff;">原材料质检标准</span>
        </el-menu-item>
        <el-menu-item index="/process-engineer/semi-finished-standard">
          <el-icon style="color: #fff;"><Tools /></el-icon>
          <span style="color: #fff;">半成品质检标准</span>
        </el-menu-item>
        <el-menu-item index="/process-engineer/finished-product-standard">
          <el-icon style="color: #fff;"><Star /></el-icon>
          <span style="color: #fff;">成品质检标准</span>
        </el-menu-item>
      </el-sub-menu>
    </template>
  </MainLayout>
</template>
<script setup lang="ts">
import MainLayout from '@/components/layout/MainLayout.vue'
import { 
  Setting, 
  Box, 
  Tools, 
  Star, 
  HomeFilled 
} from '@element-plus/icons-vue'
import { userInfoStore } from '@/stores/userInfo';
import { loginInfoStore } from '@/stores/loginInfo';
import { getUserInfoService } from '@/api/UsersApi.ts';
import { ElMessage } from 'element-plus';

const userInfo = userInfoStore();
const loginInfo = loginInfoStore();

const getUserInfo = async () =>{
  let result = await getUserInfoService();
  //将用户信息保存到仓库中
  userInfo.setUserInfo(result.data);
}

//当打开页面时获取当前用户基本信息
getUserInfo();
</script>